namespace jsWrite {
    //promise不阻塞进程
    function sleep(timer:number){
        return new Promise((resolve)=>{
            setTimeout(resolve, timer);
        })
    }    
    sleep(3000).then(()=>{
        console.log(2);
    })
    //阻塞进程
    function _sleep(timer:number){
        let timeStamp = Date.now()
        while((Date.now() - timeStamp) < timer);
    }

    _sleep(3000)
    console.log(1);
    
}